package controllers;

import play.Logger;
import client.RestException;
import client.YouGoClient;

import com.ineatconseil.yougo.dto.UserDto;

public class Security extends Secure.Security {

	static boolean authenticate(String username, String password) {
		try {
			YouGoClient client = new YouGoClient();
			UserDto userDto;
			userDto = client.getUserDto(username);
			if (userDto != null) {
				session.put("fullname", userDto.getFullName());
				session.put("userid", userDto.getId());
				return true;
			}
		} catch (RestException e) {
			Logger.error("Security.authentificate : %s", e.getMessage());
			e.printStackTrace();
		}
		return false;
	}

}
